#pragma once
#ifndef __CUBE_H__
#define __CUBE_H__

#include "Utility.h"

#include "../util/D3DCommon.h"
#include "../util/PreDeclare.h"

namespace WindGE
{
	class WIND_CORE_API Cube
	{
	public:
		Cube() { reset(); }
		Cube(const Cube& cube);
		Cube(CubePtr cube);
		Cube(const XMFLOAT3& center, float width, float height, float depth);
		Cube(const XMFLOAT3& p0, const XMFLOAT3& p1);
		Cube(const XMFLOAT3& center, float length);

		~Cube(void) {}

		void reset();
		void set(const XMFLOAT3& p0, const XMFLOAT3& p1);
		void set(float radius, const XMFLOAT3& center);
		void set(float rx, float ry, float rz, const XMFLOAT3& center);
		void set(const Cube& cube);
		void set(CubePtr cube);

		XMFLOAT4X4 world_matrix() const;

		void transform(const XMMATRIX& trans);

		const XMFLOAT3& get_transform_center(const XMMATRIX& trans) const;
		const XMFLOAT3& get_transform_size(const XMMATRIX& trans) const;
		void get_transform_center_size(const XMMATRIX& trans, XMFLOAT3& center, XMFLOAT3& radius) const;

		inline float length() const { return max(max(Radius.x, Radius.y), Radius.z) * 2.0f; }

	protected:
		void update_normal();

	public:
		XMFLOAT3 Center;
		XMFLOAT3 Radius;

		XMFLOAT3 Pos0;
		XMFLOAT3 Pos1;

		XMFLOAT3 Normal0;
		XMFLOAT3 Normal1;
		XMFLOAT3 Normal2;
		XMFLOAT3 Normal3;
	};
}

#endif // !__CUBE_H__

